package com.education.api.controller.admin.system;

import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.education.business.service.system.ExamRoomService;
import com.education.common.model.PageInfo;
import com.education.common.utils.Result;
import com.education.model.dto.ExamRoomDto;
import com.education.model.entity.BaseEntity;
import com.education.model.entity.ExamRoom;
import com.education.model.request.PageParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


/**
 * 考场管理
 */
@RestController
@RequestMapping("/system/examRoom")
public class ExamRoomController {
    @Autowired
    private ExamRoomService examRoomService;



    /**
     * 考场列表
     * @param
     * @param examRoom
     * @return
     */

//    @RequiresPermissions("system:grade:list")
    @RequestMapping(value = "/getExamRoomList",method = RequestMethod.GET)
    public Result list(PageParam pageParam, ExamRoom examRoom){
        return Result.success(examRoomService.getExamRoomList(pageParam,examRoom));
    }
    /**
     * 保存或添加考场
     * @param examRoom
     * @return
     */
    @RequestMapping(value = "/addExamRoom",method = RequestMethod.GET)
    public Result addExamRoom( ExamRoom examRoom){
        System.out.println(examRoom.getName());
        return Result.success(examRoomService.saveOrUpdate(examRoom));
    }

    //修改考场
    @GetMapping(value = "/updateExamRoom")
    public Result updateExamRoom( ExamRoom examRoom){

        return Result.success(examRoomService.saveOrUpdate(examRoom));
    }

    //删除考场
    @GetMapping(value = "/deleteExamRoomById")
    public Result deleteExamRoomById(@RequestParam("id") Integer id){
        return Result.success(examRoomService.deleteById(id));
    }

    //获取未安排的考场
    @GetMapping(value = "/selectAllNoArrangeRoom")
    public Result selectAllNoArrangeRoom(PageParam pageParam, ExamRoom examRoom){
        return Result.success(examRoomService.selectAllNoArrangeRoom(pageParam, examRoom));
    }
}

